home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / sprite.X11R3 / RCS / spriteInit.c,v < prev    next >
Encoding:
Text File  |  1989-11-19  |  13.8 KB  |  594 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.8
  10. date     89.11.18.20.57.30;  author tve;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     89.10.08.16.04.31;  author tve;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     88.03.27.21.17.08;  author deboor;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     87.08.04.17.29.42;  author deboor;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     87.07.07.18.00.52;  author deboor;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     87.06.30.19.08.36;  author deboor;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     87.06.20.19.56.42;  author deboor;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     87.06.16.12.20.52;  author deboor;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @Initialization functions
  52. @
  53.  
  54.  
  55. 1.8
  56. log
  57. @first working version with CG4 and CG6 for SPARC. CG4 for sun3 not yet ok.
  58. @
  59. text
  60. @/*-
  61.  * spriteInit.c --
  62.  *    Initialization functions for screen/keyboard/mouse, etc.
  63.  *
  64.  * Copyright (c) 1987 by the Regents of the University of California
  65.  *
  66.  * Permission to use, copy, modify, and distribute this
  67.  * software and its documentation for any purpose and without
  68.  * fee is hereby granted, provided that the above copyright
  69.  * notice appear in all copies.  The University of California
  70.  * makes no representations about the suitability of this
  71.  * software for any purpose.  It is provided "as is" without
  72.  * express or implied warranty.
  73.  *
  74.  *
  75.  */
  76. #ifndef lint
  77. static char rcsid[] =
  78. "$Header: /mic/X11R3/src/cmds/Xsprite/ddx/sprite/RCS/spriteInit.c,v 1.7 89/10/08 16:04:31 tve Exp Locker: tve $ SPRITE (Berkeley)";
  79. #endif lint
  80.  
  81. #include    "spriteddx.h"
  82. #include    <servermd.h>
  83. #include    "opaque.h"
  84.  
  85. extern void spriteMouseProc();
  86. extern void spriteKbdProc();
  87. extern Bool spriteBW2Probe();
  88. extern Bool spriteCG4Probe();
  89. extern Bool spriteCG6Probe();
  90.  
  91. extern GCPtr CreateScratchGC();
  92.  
  93.     /* What should this *really* be? */
  94. #define MOTION_BUFFER_SIZE 0
  95.  
  96. /*
  97.  * Data describing each type of frame buffer. The probeProc is called to
  98.  * see if such a device exists and to do what needs doing if it does. devName
  99.  * is the expected name of the device in the file system. Note that this only
  100.  * allows one of each type of frame buffer. This may need changing later.
  101.  */
  102. static struct {
  103.     Bool    (*probeProc)();
  104. } spriteFbData[] = {
  105.     spriteBW2Probe, spriteCG4Probe, spriteCG6Probe,
  106. };
  107.  
  108. /*
  109.  * NUMSCREENS is the number of supported frame buffers (i.e. the number of
  110.  * structures in spriteFbData which have an actual probeProc).
  111.  */
  112. #define NUMSCREENS (sizeof(spriteFbData)/sizeof(spriteFbData[0]))
  113. #define NUMDEVICES 2
  114.  
  115. fbFd    spriteFbs[NUMSCREENS];  /* Space for descriptors of open frame buffers */
  116.  
  117. static PixmapFormatRec    formats[] = {
  118.     1, 1, BITMAP_SCANLINE_PAD,    /* 1-bit deep */
  119.     8, 8, BITMAP_SCANLINE_PAD,    /* 8-bit deep */
  120. };
  121. #define NUMFORMATS    sizeof(formats)/sizeof(formats[0])
  122.  
  123. /*-
  124.  *-----------------------------------------------------------------------
  125.  * InitOutput --
  126.  *    Initialize screenInfo for all actually accessible framebuffers.
  127.  *    I kept this like the sun version just because you never know when
  128.  *    support for multiple video devices might be added to Sprite...
  129.  *
  130.  * Results:
  131.  *    screenInfo init proc field set
  132.  *
  133.  * Side Effects:
  134.  *    None
  135.  *
  136.  *-----------------------------------------------------------------------
  137.  */
  138.  
  139. InitOutput(screenInfo, argc, argv)
  140.     ScreenInfo       *screenInfo;
  141.     int           argc;
  142.     char          **argv;
  143. {
  144.     int           i, index;
  145.  
  146.     screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
  147.     screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
  148.     screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
  149.     screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
  150.  
  151.     screenInfo->numPixmapFormats = NUMFORMATS;
  152.     for (i=0; i< NUMFORMATS; i++)
  153.     {
  154.         screenInfo->formats[i] = formats[i];
  155.     }
  156.  
  157.     for (i = 0, index = 0; i < NUMSCREENS; i++) {
  158.     if ((*spriteFbData[i].probeProc) (screenInfo, index, i, argc, argv)) {
  159.         /* This display exists OK */
  160.         index++;
  161.     } else {
  162.         /* This display can't be opened */
  163.         ;
  164.     }
  165.     }
  166.     if (index == 0)
  167.     FatalError("Can't find any displays\n");
  168.  
  169.     spriteInitCursor();
  170. }
  171.  
  172. /*-
  173.  *-----------------------------------------------------------------------
  174.  * InitInput --
  175.  *    Initialize all supported input devices...what else is there
  176.  *    besides pointer and keyboard?
  177.  *    NOTE: InitOutput must have already been called.
  178.  *
  179.  * Results:
  180.  *    None.
  181.  *
  182.  * Side Effects:
  183.  *    Two DeviceRec's are allocated and registered as the system pointer
  184.  *    and keyboard devices.
  185.  *
  186.  *-----------------------------------------------------------------------
  187.  */
  188. /*ARGSUSED*/
  189. InitInput(argc, argv)
  190.     int        argc;
  191.     char    **argv;
  192. {
  193.     DevicePtr p, k;
  194.     static int  zero = 0;
  195.     
  196.     p = AddInputDevice(spriteMouseProc, TRUE);
  197.  
  198.     k = AddInputDevice(spriteKbdProc, TRUE);
  199.  
  200.     RegisterPointerDevice(p, MOTION_BUFFER_SIZE);
  201.     RegisterKeyboardDevice(k);
  202.  
  203.     spriteCheckInput = 0;
  204.     SetInputCheck (&zero, &spriteCheckInput);
  205.  
  206.     screenInfo.screen[0].blockData =
  207.     screenInfo.screen[0].wakeupData = (pointer)k;
  208. }
  209.  
  210. /*-
  211.  *-----------------------------------------------------------------------
  212.  * spriteQueryBestSize --
  213.  *    Supposed to hint about good sizes for things.
  214.  *
  215.  * Results:
  216.  *    Perhaps change *pwidth (Height irrelevant)
  217.  *
  218.  * Side Effects:
  219.  *    None.
  220.  *
  221.  *-----------------------------------------------------------------------
  222.  */
  223. /*ARGSUSED*/
  224. void
  225. spriteQueryBestSize(class, pwidth, pheight)
  226.     int            class;    /* Object class being queried */
  227.     short         *pwidth;    /* Width of object */
  228.     short         *pheight;    /* Height of object */
  229. {
  230.     unsigned int  width,
  231.           test;
  232.  
  233.     switch(class) {
  234.       case CursorShape:
  235.       case TileShape:
  236.       case StippleShape:
  237.       width = *pwidth;
  238.       if (width > 0) {
  239.           /*
  240.            * Return the closes power of two not less than what they gave
  241.            * me
  242.            */
  243.           test = 0x80000000;
  244.           /*
  245.            * Find the highest 1 bit in the width given
  246.            */
  247.           while(!(test & width)) {
  248.          test >>= 1;
  249.           }
  250.           /*
  251.            * If their number is greater than that, bump up to the next
  252.            *  power of two
  253.            */
  254.           if((test - 1) & width) {
  255.          test <<= 1;
  256.           }
  257.           *pwidth = test;
  258.       }
  259.       /*
  260.        * We don't care what height they use
  261.        */
  262.       break;
  263.     }
  264. }
  265.  
  266. /*-
  267.  *-----------------------------------------------------------------------
  268.  * spriteScreenInit --
  269.  *    Things which must be done for all types of frame buffers...
  270.  *    Should be called last of all.
  271.  *
  272.  * Results:
  273.  *    None.
  274.  *
  275.  * Side Effects:
  276.  *    The graphics context for the screen is created. The CreateGC,
  277.  *    CreateWindow and ChangeWindowAttributes vectors are changed in
  278.  *    the screen structure.
  279.  *
  280.  *-----------------------------------------------------------------------
  281.  */
  282. void
  283. spriteScreenInit (pScreen)
  284.     ScreenPtr      pScreen;
  285. {
  286.     fbFd          *fb;
  287.     DrawablePtr      pDrawable;
  288.     BITS32        junk;
  289.  
  290.     fb = &spriteFbs[pScreen->myNum];
  291.  
  292.     /*
  293.      * We need a GC for the cursor functions. We also don't want to
  294.      * have to allocate one each time. Note that it is allocated before
  295.      * CreateGC is intercepted so there are no extra indirections when
  296.      * drawing the cursor...
  297.      */
  298.     fb->pGC = CreateScratchGC (pScreen, pScreen->rootDepth);
  299.     fb->pGC->graphicsExposures = FALSE;
  300.     
  301.     /*
  302.      * Preserve the "regular" functions
  303.      */
  304.     fb->CreateGC =                    pScreen->CreateGC;
  305.     fb->CreateWindow =                     pScreen->CreateWindow;
  306.     fb->ChangeWindowAttributes =        pScreen->ChangeWindowAttributes;
  307.     fb->GetImage =                    pScreen->GetImage;
  308.     fb->GetSpans =                    pScreen->GetSpans;
  309.  
  310.     /*
  311.      * Interceptions
  312.      */
  313.     pScreen->CreateGC =                    spriteCreateGC;
  314.     pScreen->CreateWindow =             spriteCreateWindow;
  315.     pScreen->ChangeWindowAttributes =     spriteChangeWindowAttributes;
  316.     pScreen->QueryBestSize =            spriteQueryBestSize;
  317.     pScreen->GetImage =                    spriteGetImage;
  318.     pScreen->GetSpans =                    spriteGetSpans;
  319.  
  320.     /*
  321.      * Cursor functions
  322.      */
  323.     pScreen->RealizeCursor =             spriteRealizeCursor;
  324.     pScreen->UnrealizeCursor =            spriteUnrealizeCursor;
  325.     pScreen->DisplayCursor =             spriteDisplayCursor;
  326.     pScreen->SetCursorPosition =        spriteSetCursorPosition;
  327.     pScreen->CursorLimits =             spriteCursorLimits;
  328.     pScreen->PointerNonInterestBox =     spritePointerNonInterestBox;
  329.     pScreen->ConstrainCursor =             spriteConstrainCursor;
  330.     pScreen->RecolorCursor =             spriteRecolorCursor;
  331.  
  332.     /*
  333.      * Set pixel values for sun's view of the world...
  334.      */
  335.     pScreen->whitePixel = 0;
  336.     pScreen->blackPixel = 1;
  337.  
  338.     /*
  339.      *    Block/Unblock handlers
  340.      */
  341.     screenInfo.screen[0].BlockHandler = spriteBlockHandler;
  342.     screenInfo.screen[0].WakeupHandler = spriteWakeupHandler;
  343. }
  344.  
  345. @
  346.  
  347.  
  348. 1.7
  349. log
  350. @added X11R3 mods
  351. @
  352. text
  353. @d19 1
  354. a19 1
  355. "$Header: spriteInit.c,v 1.6 88/03/27 21:17:08 deboor Exp $ SPRITE (Berkeley)";
  356. d29 2
  357. a30 2
  358. extern Bool spriteCG2CProbe();
  359. extern Bool spriteCG4CProbe();
  360. d32 1
  361. a44 1
  362.     char    *devName;
  363. d46 1
  364. a46 3
  365.     spriteBW2Probe,      "/dev/bwtwo0",
  366.     spriteCG2Probe,      "/dev/cgtwo0",
  367.     spriteCG4Probe,      "/dev/cgfour0",
  368. d95 1
  369. a95 4
  370.         screenInfo->formats[i].depth = formats[i].depth;
  371.         screenInfo->formats[i].bitsPerPixel = formats[i].bitsPerPixel;
  372.         screenInfo->formats[i].bitsPerPixel = formats[i].bitsPerPixel;
  373.         screenInfo->formats[i].scanlinePad = formats[i].scanlinePad;
  374. d99 1
  375. a99 1
  376.     if ((* spriteFbData[i].probeProc) (screenInfo, index, i, argc, argv)) {
  377. d147 2
  378. a283 2
  379.     screenInfo.screen[0].blockData =
  380.     screenInfo.screen[0].wakeupData = (pointer)k;
  381. @
  382.  
  383.  
  384. 1.6
  385. log
  386. @*** empty log message ***
  387. @
  388. text
  389. @d19 1
  390. a19 1
  391. "$Header: spriteInit.c,v 1.5 87/08/04 17:29:42 deboor Exp $ SPRITE (Berkeley)";
  392. d23 1
  393. a23 1
  394. #include    "servermd.h"
  395. a28 2
  396. extern Bool spriteCG2MProbe();
  397. #ifdef DO_COLOR
  398. d30 1
  399. a30 1
  400. #endif
  401. a31 5
  402. #ifdef DO_COLOR
  403. #define spriteCG2Probe    spriteCG2CProbe
  404. #else
  405. #define spriteCG2Probe    spriteCG2MProbe
  406. #endif
  407. d48 1
  408. d62 1
  409. d112 2
  410. a151 7
  411.     /*
  412.      * XXX: Shouldn't really be attached to the screen...
  413.      */
  414.     screenInfo.screen[0].BlockHandler = spriteBlockHandler;
  415.     screenInfo.screen[0].WakeupHandler = spriteWakeupHandler;
  416.     screenInfo.screen[0].blockData =
  417.     screenInfo.screen[0].wakeupData = (pointer)k;
  418. d260 1
  419. d277 1
  420. a277 1
  421.      * Other
  422. d279 2
  423. a280 1
  424.     pScreen->QueryBestSize =            spriteQueryBestSize;
  425. d283 1
  426. a283 1
  427.      * Set pixel values for sun's view of the world...
  428. d285 4
  429. a288 2
  430.     pScreen->whitePixel = 0;
  431.     pScreen->blackPixel = 1;
  432. @
  433.  
  434.  
  435. 1.5
  436. log
  437. @Added pixmap format so PixmapBytePad actually works. Changed
  438. call to GetScratchGC in spriteScreenInit to be CreateScratchGC again.
  439. @
  440. text
  441. @d19 1
  442. a19 1
  443. "$Header: spriteInit.c,v 1.4 87/07/07 18:00:52 deboor Exp $ SPRITE (Berkeley)";
  444. d23 1
  445. a23 1
  446.  
  447. a116 2
  448.     if (index == 0)
  449.     FatalError("Can't find any displays\n");
  450. d126 1
  451. d137 4
  452. a140 1
  453. InitInput()
  454. d154 8
  455. d166 56
  456. d284 5
  457. @
  458.  
  459.  
  460. 1.4
  461. log
  462. @reorganized InitOutput so the pixmap width padding stuff gets setup
  463. correctly by AddScreen
  464. @
  465. text
  466. @d19 1
  467. a19 1
  468. "$Header: spriteInit.c,v 1.3 87/06/30 19:08:36 deboor Exp $ SPRITE (Berkeley)";
  469. d66 4
  470. a69 2
  471. PixmapFormatRec    *formats;    /* None for now! */
  472. #define NUMFORMATS    0
  473. d182 1
  474. a182 4
  475.      * have to allocate one each time. Since the GCPerDepthArray for
  476.      * the screen hasn't been allocated yet, this call to GetScratchGC
  477.      * will give us a freshly-allocated, pristine scratch GC to use,
  478.      * and we never have to free it... Note that it is allocated before
  479. d186 2
  480. a187 1
  481.     fb->pGC = GetScratchGC (pScreen->rootDepth, pScreen);
  482. d196 1
  483. d205 1
  484. @
  485.  
  486.  
  487. 1.3
  488. log
  489. @Nuked GC in fbFd
  490. @
  491. text
  492. @d19 1
  493. a19 1
  494. "$Header: spriteInit.c,v 1.2 87/06/20 19:56:42 deboor Exp $ SPRITE (Berkeley)";
  495. a91 13
  496.     for (i = 0, index = 0; i < NUMSCREENS; i++) {
  497.     if ((* spriteFbData[i].probeProc) (screenInfo, index, i, argc, argv)) {
  498.         /* This display exists OK */
  499.         index++;
  500.     } else {
  501.         /* This display can't be opened */
  502.         ;
  503.     }
  504.     }
  505.     if (index == 0)
  506.     FatalError("Can't find any displays\n");
  507.  
  508.     screenInfo->numScreens = index;
  509. d106 12
  510. d179 11
  511. d218 1
  512. a218 1
  513.      * Set pixel values for sprite's view of the world...
  514. @
  515.  
  516.  
  517. 1.2
  518. log
  519. @adapted to Beta-0
  520. @
  521. text
  522. @d19 1
  523. a19 1
  524. "$Header: spriteInit.c,v 1.1 87/06/16 12:20:52 deboor Exp $ SPRITE (Berkeley)";
  525. a177 16
  526.  
  527.     /*
  528.      * Prepare the GC for cursor functions on this screen.
  529.      * Do this before setting interceptions to avoid looping when
  530.      * putting down the cursor...
  531.      */
  532.     pDrawable = (DrawablePtr)(pScreen->devPrivate);
  533.  
  534.     fb->pGC = CreateScratchGC (pDrawable, (BITS32)0, (long *)0, &junk);
  535.  
  536.     /*
  537.      * By setting graphicsExposures false, we prevent any expose events
  538.      * from being generated in the CopyArea requests used by the cursor
  539.      * routines.
  540.      */
  541.     fb->pGC->graphicsExposures = FALSE;
  542. @
  543.  
  544.  
  545. 1.1
  546. log
  547. @Initial revision
  548. @
  549. text
  550. @d19 1
  551. a19 1
  552. "$Header: spriteInit.c,v 2.9 87/05/13 15:06:46 deboor Exp $ SPRITE (Berkeley)";
  553. a39 2
  554. #define    XDEVICE    "XDEVICE"
  555.  
  556. d73 2
  557. a74 1
  558.  *    The
  559. a94 1
  560.         screenInfo->CloseScreen[index] = (Bool (*)())NoopDDA;
  561. d119 1
  562. a119 1
  563.     sunInitCursor();
  564. d142 1
  565. a142 3
  566.     p = AddInputDevice(
  567.     MakeDevice(DEVICE_MOUSE, SUN_MS3, M_SUN, 0),
  568.     spriteMouseProc, TRUE);
  569. d144 1
  570. a144 3
  571.     k = AddInputDevice(
  572.     MakeDevice(DEVICE_KEYBOARD, 0, M_SUN, 0),
  573.     spriteKbdProc, TRUE);
  574. d186 1
  575. a186 1
  576.     fb->pGC = CreateGC (pDrawable, (BITS32)0, (long *)0, &junk);
  577. d206 4
  578. a209 4
  579.     pScreen->CreateGC =                    sunCreateGC;
  580.     pScreen->CreateWindow =             sunCreateWindow;
  581.     pScreen->ChangeWindowAttributes =     sunChangeWindowAttributes;
  582.     pScreen->GetImage =                    sunGetImage;
  583. d214 8
  584. a221 8
  585.     pScreen->RealizeCursor =             sunRealizeCursor;
  586.     pScreen->UnrealizeCursor =            sunUnrealizeCursor;
  587.     pScreen->DisplayCursor =             sunDisplayCursor;
  588.     pScreen->SetCursorPosition =        sunSetCursorPosition;
  589.     pScreen->CursorLimits =             sunCursorLimits;
  590.     pScreen->PointerNonInterestBox =     sunPointerNonInterestBox;
  591.     pScreen->ConstrainCursor =             sunConstrainCursor;
  592.     pScreen->RecolorCursor =             sunRecolorCursor;
  593. @
  594.